package java_class_work.week08;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author Tiam
 * @Date 2022/10/31 17:12
 * @Description:
 */
public class inetAddressDemo {
    public static void main(String[] args) {
        try {
            InetAddress localHost = InetAddress.getLocalHost();
            System.out.println(localHost.toString());
            System.out.println(localHost.getHostName());
            System.out.println(localHost.getHostAddress());

            InetAddress baidu = InetAddress.getByName("www.baidu.com");
            System.out.println(baidu.toString());

            InetAddress github = InetAddress.getByName("www.github.com");
            System.out.println(github.toString());

            InetAddress bing = InetAddress.getByName("www.bing.com");
            System.out.println(bing.toString());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
